
package com.nn.smart.bus.controller;

import com.nn.smart.bus.commons.mybatis.annotation.DataFilter;
import com.nn.smart.bus.commons.tools.utils.Result;
import com.nn.smart.bus.dto.SimpleAreaDTO;
import com.nn.smart.bus.dto.SysSimpleDeptDTO;
import com.nn.smart.bus.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 获取行政区划
 *
 * @author nanning
 */
@RestController
@RequestMapping("area")
public class AreaController {

    @Autowired
    private AreaService areaService;

    /**
     * 根据区划ID，获取下属区域列表
     *
     * @param areaId
     * @return com.nn.smart.commons.tools.utils.Result<java.util.List < com.nn.smart.dto.AreaDTO>>
     * @author nanning
     */
    @GetMapping("listSimple/{areaId}")
    public Result<List<SimpleAreaDTO>> listSimpleAreaInfo(@PathVariable("areaId") String areaId) {
        return this.areaService.listSimpleAreaInfo(areaId);
    }

    /**
     * 数据权限控制用户可操作的部门
     *
     * @param params
     * @return com.nn.smart.bus.commons.tools.utils.Result<java.util.List < com.nn.smart.bus.dto.SysSimpleDeptDTO>>
     * @author nanning
     */
    @GetMapping("listSimpleDept")
    @DataFilter(tableAlias = "temp", deptId = "id", prefix = "WHERE")
    public Result<List<SysSimpleDeptDTO>> listSimpleDeptInfo(@RequestParam Map<String, Object> params) {
        return this.areaService.listSimpleDeptInfo(params);
    }
}
